#include #include #include #include using namespace std; //void main() //{ // ifstream fin("Bible.txt"); // // string line; // string bookName; // string verse; // int chapterNumber; // int verseNumber; // // while (!fin.eof()) // { // getline(fin, line); // // if (!line.empty()) // { // if (isdigit(line[0])) // { // //001:001 In the beginning God created the heaven and the earth. // //start of a new verse // string chapterText = line.substr(0,3); // string verseText = line.substr(4, 3); // verse = line.substr(8); // chapterNumber = atoi(chapterText.c_str()); // verseNumber = atoi(verseText.c_str()); // //loop to read the rest of verse // if (verse.find("righteous") != string::npos) // { // int preIndex = verse.find("righteous") - 1; // int postIndex = verse.find("righteous") + strlen("righteous") + 1; // if (preIndex == 0 || !isalpha(verse[preIndex])) // { // if (postIndex >= verse.length() || !isalpha(verse[postIndex])) // { // cout << bookName << " " << chapterNumber << ":" << verseNumber << endl; // cout << verse << endl; // } // } // } // } // else if(line[0] == 'B') // { // bookName = line.substr(8); // } // } // // } // // fin.close(); //} void main() { ofstream fout("numbers.dat",ios_base::binary); int A[100]; for (int i = 0; i < 100; i++) { A[i] = i; } for (int i = 0; i < 100; i++) { //fout << A[i]; //write the 4 bytes that are in the current cell of the array A //fout.write((char*)&A[i], 4); fout.write((char*)(A+i), 4); } fout.close(); ifstream fin("numbers.dat" , ios_base::binary); int B[100]; int i = 0; //g - get pointer fin.seekg(200); while (!fin.eof()) { fin.read((char*)(B + i), 4); i++; } fin.close(); for (int i = 0; i < 100; i++) { cout << B[i] << endl; } }